<include file="Public:header" />
<div id="container" class=" container waterfall">
<volist name="list" id="vo">
	<div class="babycontent">
		<a href="#">
		<img src="{$vo.picurl}" width="246px" height="200px" class="img-rounded">
		<h4 class="text-center">{$vo.babyname}</h4>
		</a>
		<div class="contcont">
		<p class="text_cont lead">价格：<span style="color:red;">￥{$vo.babymoney}</span></p>
		<button type="button" class="btn btn-default btn-center">查看详情>></button>
		</div>

		<div class="contfoot">
			<h5>发布日期：{$vo.day|date='Y-m-d',###}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;By:{$vo.clientname}</h5>
		</div>
	</div>
</volist>
</div>
<div id="loading" class="loading-wrap">
	<span class="loading">加载中，请稍后...</span>
</div>
<script type="text/javascript">
$(function(){
    //执行瀑布流
    var $container = $('#container');
	  $container.masonry({
	    itemSelector : '.item',
	    isAnimated: true
	  });

	var loading = $("#loading").data("on", false);
	$(window).scroll(function(){
		if(loading.data("on")) return;
		if($(document).scrollTop() > 
			$(document).height()-$(window).height()-$('.footer').height()){
			//加载更多数据
			loading.data("on", true).fadeIn();
			$.get(
				"/Index/getMore", 
				{"last_id" : $("#container>div:last>input").val()},
				function(data){
					var html = "";
					if($.isArray(data)){
						for(i in data){
							html += "<div class=\"babycontent\"><img src="{$vo.picurl}" width=\"246px\" height=\"200px\" class=\"img-rounded\"></div>"
							html += "<input type=\"hidden\" name=\"id\" value=\""+data[i]['id']+"\"/></div>";
						}
						var $newElems = $(html).css({ opacity: 0 }).appendTo($container);
						$newElems.imagesLoaded(function(){
							$newElems.animate({ opacity: 1 });
							$container.masonry( 'appended', $newElems, true ); 
				        });
				        loading.data("on", false);
					}
					loading.fadeOut();
				},
				"json"
			);
		}
	});
});
</script>
</body>
</html>